export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
headpath="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
sdkpath="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
fwpath="/System/Library/Frameworks"
jdkpath="/Library/Java/JavaVirtualMachines"
#llvmpath=/usr/local/Cellar/llvm/*/include/c++/v1
#gccpath=/usr/local/Cellar/gcc/*/include/c++/*
hb="/usr/local/Cellar"
hbc="/usr/local/Caskroom"
lb="/usr/local/bin"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/scientificworld/.sdkman"
[[ -s "/Users/scientificworld/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/scientificworld/.sdkman/bin/sdkman-init.sh"
export PATH="/usr/local/opt/llvm/bin:$PATH"
export PATH="/usr/local/opt/sqlite/bin:$PATH"
export PATH="/usr/local/opt/libxml2/bin:$PATH"
export PATH="/usr/local/opt/libarchive/bin:$PATH"
#export PATH="/usr/local/opt/bochs/bin:$PATH"
#alias dongbei=~/dongbei/src/dongbei.py
#alias dongbeit=~/dongbei/test/dongbei_test.py
#alias dongbeino=~/dongbei/src/dongbeino.py
#alias ip=ifconfig | sed -n "13,13p" | awk '{print $2}'
#export ~/.bash_profile
function initx(){
	if [ -n "$1" ];then
		initfile=$1
	else
		read initfile
	fi
	if [ -n "$2" ];then
		initshell=$(which $2)
	else
		initshell=/bin/bash
	fi
	if [ ! -e "$initfile" ];then
		touch "$initfile" && chmod +x "$initfile" && echo '#!'$initshell'' >> "$initfile" && echo >> "$initfile" #&& vim "$initfile"
	fi
	unset initfile initshell
}
function dirof(){
	cor="$PWD"
	for loop in "$@"
	do
		cd "$(dirname "$(which "$loop")")"
		if [ -h "$loop" ];then
			cd "$(dirname "$(readlink "$(which "$loop")")")"
		fi
		echo "$PWD"
	done
	cd "$cor"
	unset cor
}
function justecho(){
	echo "$1"
}
function pipup(){
	tmp="$(pip3 list --outdate | awk '{print $1}')"
	echo "$tmp" | sed -n 3,$(echo "$tmp" | sed -n '$=')p | xargs pip3 install --upgrade
	unset tmp
}
export PATH="$PATH:/Users/scientificworld/.dotnet/tools"
export PATH="$PATH:/Users/scientificworld/Library/Python/3.7/bin"
export PATH="/usr/local/opt/libarchive/bin:$PATH"
#export PATH="/usr/local/opt/ncurses/bin:$PATH"
export PATH="/usr/local/opt/python@3.8/bin:$PATH"
# eval $(thefuck --alias)
# no python, speed up!!!
fuck () {
    TF_PYTHONIOENCODING=$PYTHONIOENCODING;
    export TF_SHELL=zsh;
    export TF_ALIAS=fuck;
    TF_SHELL_ALIASES=$(alias);
    export TF_SHELL_ALIASES;
    TF_HISTORY="$(fc -ln -10)";
    export TF_HISTORY;
    export PYTHONIOENCODING=utf-8;
    TF_CMD=$(
        thefuck THEFUCK_ARGUMENT_PLACEHOLDER $@
    ) && eval $TF_CMD;
    unset TF_HISTORY;
    export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
    test -n "$TF_CMD" && print -s $TF_CMD
}
alias iterm="open /Applications/iTerm.app"
#eval $(opam env)
export PATH="$PATH:/opt/pkg_uninstaller"
alias ngh=nodegh
alias sqlite=sqlite3
function clearun(){
	tput smcup
	eval "$1"
	tput rmcup
}
#function mytty(){
#	echo ${TTY#*/dev/}
#}
function killtty(){
	if [ ! -e "/dev/ttys$1" ];then
		return
	fi
	kill -9 `ps -e | grep "[t]tys$1" | awk '{print $1}'`
	#kill -9 `ps ax | grep "[s]$1" | awk '{print $1}'`
}
#alias shanghai=~/shanghai/src/shanghai.py
alias rigforever="while true;do;rig;sleep 1;echo;done"
alias starwars="telnet towel.blinkenlights.nl"
#alias mapscii="telnet mapscii.me"
function monit(){
	cat "/dev/$1"
}
function talk(){
	if [[ ! -e "/dev/$1" || -d "/dev/$1" ]];then
		return
	fi
	cat > "/dev/$1"
}
function bomb(){
	if [[ ! -e "$2" || -d "$2" ]] || [[ ! -e "/dev/$1" || -d "/dev/$1" ]];then
		return
	fi
	cat "$2" > "/dev/$1"
}
alias ldd="otool -L"
alias cv=progress
alias cd..="cd .."
alias jsc=/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
#alias weather="curl wttr.in"
alias rm="justecho 'rm has been disabled!!'"
function weather(){
	if [ -n "$1" ];then
		echo "wttr.in/$1"
		curl "wttr.in/$1"
	else
		curl "wttr.in"
	fi
}
function header(){
	for loop in "$@"
	do
		if [ -e "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/$loop" ];then
			vim /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/"$loop"
		fi
		if [ -e "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/$loop" ];then
			vim /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"$loop"
		fi
	done
}
alias taichi=python3
#function deleteit(){
#	echo -n "Do you want to delete `pwd`?"
#	read choose
#	if [[ "$choose" == "y" ]] || [[ "$choose" == "Y" ]]
#	then
#		echo "Deleteing..."
#	fi
#}
#alias deleteit="rm -rf "`pwd`" && cd"
alias lsn="linux_logo ; screenfetch ; neofetch"
alias sysinfo=lsn
alias fcl="fortune | cowsay | lolcat"
alias fcn="fortune | cowsay | nms"
function countnum(){
	cntnum=0
	for loop in $*
	do
		let cntnum=cntnum+1
	done
	echo $cntnum
	unset loop cntnum
}
function repeatword(){
	for loop in `seq $2`
	do
		echo -n "$1"
	done
}
function comp(){
	if [ ! -e "$1" ];then
		return 1
	fi
	name="${2:-"$1.7z"}"
	7z a "$name" "$1" -mmt1
	if [ ! -n "$notrash" ];then
		trash "$1"
	fi
	unset name
	return 0
}
alias ccl=ccl64
alias shit=fuck
#alias shit='res=$(fuck 2>&1) ; echo "${res//fuck/shit}" ; unset res'
alias dog=cat
alias httpie=http
alias cls=clear
alias cgh=ghcli
alias quit=exit
#screenfetch
export PATH="/usr/local/bin/tengine/sbin:$PATH"
export PATH="/usr/local/opt/gettext/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
alias edit="open -e"
#alias editcfg="vim ~/.zshrc.pre-oh-my-zsh"
#alias chtheme="ZSH_THEME="random" && source $ZSH/oh-my-zsh.sh"
function re(){
	#echo $*
	if [ ! -n "$2" ];then
		return
	fi
	cmd=${3:-mv}
	loca="$(which "$1")"
	#echo $cmd $loca
	if [ ! -e "$loca" ];then
		return
	fi
	echo "$cmd "$loca" "$(dirname "$loca")/$2""
	$cmd "$loca" "$(dirname "$loca")/$2"
	unset loca cmd
}
function gfre(){
	if [ ! -n "$1" ];then
		return
	fi
	if [ ! -e "$1.cpp" ];then
		cat > "$1.cpp" << eof
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("$1.in","r",stdin);
	//freopen("$1.out","w",stdout);
	return 0;
}
eof
	fi
}
function remove(){
	if [ ! -n "$2" ];then
		set "$1" ".DS_Store"
	fi
	find "$1" -name "$2" | xargs trash
}
alias bpcs="BaiduPCS-Go"
alias bcps="bpcs"
alias config="vim "$HOME"/.$(basename "$SHELL")rc"
alias hist="vim "$HOME"/.$(basename "$SHELL")_history"
alias refresh="source "$HOME"/.$(basename "$SHELL")rc"
alias gitup="git add . && git commit -m '.' ; git push"
alias cor_branch="git rev-parse --abbrev-ref HEAD"
function gitme(){
	if [ ! -n "$1" ];then
		return
	fi
	cor="$(cor_branch)"
	git checkout "$1"
	if [ -n "$2" ];then
		git pull
	fi
	git merge "$cor"
	if [[ "$?" == "0" ]];then
		git push
		git checkout "$cor"
	fi
	unset cor
}
function apl_t(){
	echo ")OFF" | apl
}
function apl_s(){
	repeat ${1:-10}
	do
		apl_t 2>/dev/null | grep duration
	done
}
function repstr(){
	if [ ! -n "$2" ];then
		return
	fi
	tmp1="`grep "$1" -rl "$PWD"`"
	#tmp2="${tmp1//.\//}"
	tmp2="${tmp1//${PWD}\//}"
	for loop in $tmp2
	do
		#echo $tmp2
		sed -i "" "s/$1/$2/g" "$loop"
	done
	unset tmp1 tmp2
}
function swtrash(){
	if [ -n "$1" ];then
		# echo $notrash
		echo "${notrash:-0}"
		return
	fi
	if [ -n "$notrash" ];then
		unset notrash
	else
		notrash=1
	fi
}
#alias rename="re "$1" "$2""
#alias linkit="re "$1" "$2" ln"
baidu="www.baidu.com"
RTTY="${TTY##*/dev/}"
function rename(){ re "$1" "$2" }
function linkit(){ re "$1" "$2" ln }
export PATH="/usr/local/opt/ruby/bin:$PATH"
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
test -r /Users/scientificworld/.opam/opam-init/init.zsh && . /Users/scientificworld/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true
export PATH="$(echo -n /usr/local/Cellar/gcc/*/libexec/gcc/x86_64-apple-darwin19/*):$PATH"
export PATH="/usr/local/opt/tcl-tk/bin:$PATH"
export PATH="/usr/local/opt/curl-openssl/bin:$PATH"
alias ard=arduino-cli
alias redis=redis-cli
alias bf=brainfuck
alias lg=license-generator
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
export PATH="/usr/local/opt/qt/bin:$PATH"
export PATH="/usr/local/opt/llvm/bin:$PATH"
export PATH="/usr/local/opt/bc/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"
export CSMITH_PATH="/usr/local/opt/csmith/include/csmith-2.3.0"
export PATH="$HOME/go/bin:$PATH"
alias bd=". bd -si"
alias ll="ls -l"
alias la="ls -a"
alias getroot="sudo mount -uw /"
alias getip="curl -s ifconfig.co"
alias aria2cd="aria2c -x 16 -s 80"
cxpath="$HOME/Library/Application Support/CrossOver/Bottles" 
cxapp="/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin"
alias cxwine="$cxapp/wine"
alias cxbottle="$cxapp/cxbottle"
function fdfw(){
	if [ ! -n "$1" ];then
		return 1
	fi
	pt="/System/Library/"
	div="$1"
	while true
	do
		ans="${div%%/*}"
		if [[ "$ans" == "$div" ]];then
			pt="${pt}Frameworks/${ans}.framework/Headers"
			echo "$pt"
			return 0
		else
			div="${div#*/}"
			pt="${pt}Frameworks/${ans}.framework/"
		fi
	done
}
function fixfw(){
	for loop in "$@"
	do
		fwpt="`fdfw "$loop"`"
		if [ -e "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk${fwpt}" ];then
			sudo ln -sf "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk${fwpt}" "$fwpt"
		fi
	done
}
function cxwine_ex(){
	now="`pwd`"
	base="`basename "$1"`"
	cd "`dirname "$1"`"
	shift
	cxwine "$base" "$@"
	cd "$now"
	unset now base
}
alias uhbtfatapl="brew search --desc compiler ; brew search --desc interpreter ; brew search --desc bytecode ; brew search --desc vm" # Use HomeBrew To Find All Things About Programming Languages
# axe init
store.axe()
{
    /usr/local/axe/meta/gualang /usr/local/axe/meta/bin/store.gua "$@"
    hash -r
}
# axe init
alias axe="store.axe"
srvpath="/Library/WebServer/Documents"
function equal(){
	if [[ ! -f "$1" || ! -f "$2" ]];then
		return 2
	fi
	if [[ "`md5 -q "$1"`" == "`md5 -q "$2"`" ]];then
		echo "same"
		return 0
	else
		echo "different"
		return 1
	fi
}
function cntfile(){
	for lbwnb in "$@"
	do
		if [ ! -d "$lbwnb" ];then
			continue
		else
			echo "$lbwnb:"
			tree "$lbwnb" | tail -n 1
		fi
	done
}
export PATH="/opt/pkg/bin:$PATH"
export ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/"
trashdir="$HOME/.local/share/Trash"
alias _cxfuck="killall -9 wine32on64-preloader wine64-preloader"
function _cxcommand(){
	x="$2"
	y="$1"
	shift 2
	cxbottle --bottle "$x" --"$y" "$@"
}
alias _cxdelete="_cxcommand delete"
alias _cxdefault="_cxcommand default"
function _cxremake(){
	if [ ! -n "$1" ];then
		return
	fi
	_cxdelete "$1"
	if [ -n "$2" ];then
		cxbottle --bottle "$1" --create --template "$2"
	else
		cxbottle --bottle "$1" --create
	fi
	if [ ! -n "$3" ];then
		_cxdefault "$1"
	fi
}
function _cxbackup(){
	if [ ! -n "$2" ];then
		return
	fi
	7z a "$2" "$cxpath/$1/drive_c/users/crossover/Application Data" "$cxpath/$1/drive_c/users/crossover/AppData"
}
function _cxrecover(){
	if [ ! -f "$2" ];then
		return
	fi
	7z x "$2" -o"$cxpath/$1/drive_c/users/crossover"
}
alias mingw-gcc="x86_64-w64-mingw32-gcc"
alias mingw-g++="x86_64-w64-mingw32-g++"
alias restrash="mv $lb/trash $lb/trash-cli && brew link trash"
alias lastlog="git log | head -n 1 | awk '{print \$2}'"
alias anywhere="sudo spctl --master-disable"
alias cshalloc="tcsh -c \"alloc\""
alias ktfad="killall -9 AdobeGCClient" # Kill The Fucking Adobe Detection
alias dtfad="sudo rm -rf '/Library/Application Support/Adobe/AdobeGCClient'"
function sutrash(){
	if [ ! -n "$1" ];then
		return
	fi
	if [ -n "$2" ];then
		chflags "no$2" "${1%/*}"
	fi
	sudo mv "$1" "$HOME/.Trash"
	if [ -n "$2" ];then
		chflags "$2" "${1%/*}"
	fi
}
function bootable(){
	if [ ! -n "$1" ];then
		return
	fi
	if [ ! -n "$2" ];then
		set "$1" "${1}.vhd"
	fi
	if [ -e "$2" ];then
		trash "$2"
	fi
	VBoxManage convertfromraw "$1" "$2" --format VHD --variant Fixed
}
function fastgit(){
	arg=()
	cor=0
	for tmp in "$@"
	do
		let cor=cor+1
		if [[ "$tmp" == "https://github.com"* ]]
		then
			tmp="${tmp/https:\/\/github.com/https://hub.fastgit.xyz}"
		elif [[ "$tmp" == "github.com"* ]]
		then
			tmp="${tmp/github.com/https://hub.fastgit.xyz}"
		fi
		arg[$cor]="$tmp"
	done
	#echo "${arg[@]}"
	git "${arg[@]}"
	unset arg cor
}
function pyreq(){
	if [ ! -n "$1" ];then
		return 1
	fi
	reqs="`pip freeze`"
	for req in "$@";do
		echo "$reqs" | grep "^$req=="
	done
}
#export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/local/opt/qt/share/qt/plugins
alias pysrv="python3 -m http.server"
function phpsrv(){
	if [ ! -n "$1" ];then
		port="localhost:8000"
	else
		port="localhost:$1"
	fi
	php -S "$port"
}
alias npm_cn="npm config set registry https://registry.npm.taobao.org"
alias npm_org="npm config set registry https://registry.npmjs.org"
export PATH="/usr/local/opt/bison/bin:$PATH"
export HOMEBREW_BOTTLE_DOMAIN=http://mirrors.aliyun.com/homebrew/homebrew-bottles
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true
hbcache="$HOME/Library/Caches/Homebrew"
export PATH="/usr/local/opt/python@3.10/bin:$PATH"
. /usr/local/bin/mouse.zsh
bindkey -M emacs 'm' zle-toggle-mouse
alias wine=wine64
function title(){
	if [ ! -n "$1" ]; then
		set "Coding Terminal"
	fi
	echo -n $'\e'"]0;$1"$'\a'
}
echo "Hello World!"
